﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LiteratureManage.Domain
{
    public class PagingResult<T>
    {
        private PagingResult()
        {
            this.Items = new List<T>();
        }

        public PagingResult(IEnumerable<T> items)
        {
            this.Items = new List<T>(items);
        }

        public int PageSize { get; set; }

        public int TotalItems { get; set; }

        public int CurrentPage { get; set; }

        public int TotalPages
        {
            get
            {
                if (this.TotalItems <= 0)
                {
                    return 0;
                }

                return (int)Math.Ceiling((decimal)this.TotalItems / this.PageSize);
            }
        }

        public ICollection<T> Items { get; private set; }
    }
}
